﻿using System;
using System.Windows.Forms;
using glTech.Log4netWrapper;
using Nancy.Hosting.Self;
using Xilium.CefGlue;

namespace WebkitIISHost
{
    internal static class Program
    {
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        [STAThread]
        private static void Main()
        {
            Logger.Initialize(SystemConfig.LogConfigPath);
            Logger.LogInfo("启动。");
            CefRuntime.Load();
            var mainArgs = new CefMainArgs(new string[0]);
            int exitCode = CefRuntime.ExecuteProcess(mainArgs, null);

            if (exitCode == -1)
            {
                var settings = new CefSettings
                {
                    SingleProcess = false,
                    MultiThreadedMessageLoop = true,
                    LogSeverity = CefLogSeverity.Disable,
                    Locale = "zh-CN"
                };
                CefRuntime.Initialize(mainArgs, settings, null);
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                if (!settings.MultiThreadedMessageLoop)
                {
                    Application.Idle += (sender, e) => CefRuntime.DoMessageLoopWork();
                }
                Application.Run(new frmBrowser());
                CefRuntime.Shutdown();
            }
        }

    }
}
